﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoolERP_Entities;

namespace CoolERP_DAL
{
    public interface IUserInRolesDAL : IDAL<UserInRoles>
    {
        List<string> GetByUser(string userId);
    }

    public class UserInRolesDAL : BaseDAL<UserInRoles>, IUserInRolesDAL
    {
        public UserInRolesDAL(IUnitOfWork context)
            : base(context)
        {
        }

        public List<string> GetByUser(string userId)
        {
            List<string> list = new List<string>();
            Guid uid = Guid.Parse(userId);
            Users user = dataContext.Users.Include("UserInRoles").FirstOrDefault(c => c.Id == uid);
            foreach (var c in user.UserInRoles)
            {
                list.Add(c.Id.ToString());
            }
            return list;
        }

      

    }
}
